package com.huanri.patterns.iterator;

/**
 * @author Nemo
 * @date 2012-8-20 at MyCode
 */
public class ConcreteIterator implements Iterator {

	private Container container = null;
	private int index;
	
	public ConcreteIterator(Container container){
		index = 0;
		this.container = container;
	}
	public boolean hasNext() {
		
		return index < container.getSize();
	}

	public Object getNext() {
		Object obj = container.get(index);
        index++;
        return obj;
	}
	public void first() {
		index = 0;
	}
	public void last() {
		index = container.getSize();
	}

}
